package com.satan.juc.demo14;

import java.util.HashMap;
import java.util.Map;
import java.util.concurrent.ConcurrentHashMap;

/**
 * @Author: Demon
 * @Date: 2024/3/29 17:07
 * @Description:
 **/
public class ConcurrentHashMapDemo {
    public static void main(String[] args) {
        // 1. 构造一个空的map，即table数组还未初始化，初始化放在第一次插入数据时，默认大小为16
        ConcurrentHashMap concurrentHashMap1 = new ConcurrentHashMap();
        // 2. 给定map的大小
        ConcurrentHashMap<String, Object> concurrentHashMap2 = new ConcurrentHashMap<>(12);
        // 3. 给定一个map
        Map<String, Object> map = new HashMap<>();
        ConcurrentHashMap<String, Object> concurrentHashMap3 = new ConcurrentHashMap<>(map);
        // 4. 给定map的大小以及加载因子
        ConcurrentHashMap concurrentHashMap4 = new ConcurrentHashMap(12, 1);
        // 5. 给定map大小，加载因子以及并发度（预计同时操作数据的线程）
        ConcurrentHashMap concurrentHashMap5 = new ConcurrentHashMap(12, 1, 16);
    }
}
